package game.model.net
{
	import flash.events.Event;
	import game.model.event.NetServiceEvent;
	import game.utils.net.AMFService;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	 * ...
	 * @author Thot
	 */
	
	public class NetProxy extends Proxy implements IProxy
	{
		
		static public var NAME:String = 'NetProxy';
		private var _service:AMFService;
		
		public function NetProxy()
		{ 
			super( NAME, new Object() );
			init();
		}
		
		private function init():void 
		{
			_service = new AMFService("http://localhost/mobile-game/server/gateway.php");
			_service.addEventListener( NetServiceEvent.RECEIVE_DATA, dataHandler );
			_service.addEventListener( NetServiceEvent.NET_ERROR, errorHandler );
		}
		
		private function dataHandler( e:NetServiceEvent ):void
		{
			trace( "success:", e.body );
		}
		
		private function errorHandler( e:NetServiceEvent ):void
		{
			trace( "error:", e.body );
		}
		
	}

}